Drongo's Defensive AI
for Arma 3
v0.13

by Drongo
29 July 2022

My Discord: https://discord.gg/XSRHPEd
My Patreon: https://www.patreon.com/DrongoMods
My YouTube channel: https://www.youtube.com/channel/UCrZtKPYPS9iYzu1EAzTLYgg


REQUIREMENTS
Arma 3
CBA
LAMBS Danger


OVERVIEW
This mod adds variety and unpredictability to AI defensive positions. Tested in SP and MP.

DDAI makes defensive positions more challenging by garrisoning troops in structures (using LAMBS Danger), spawning and garrisoning bunkers, placing camo nets over vehicles and making the AI more reactive (with options to hold position, react to contact, launch counter-attacks, flee upon taking heavy casualties). Infantry units that do not garrison a bunker or structure will use LAMBS AI to patrol. Empty statics placed in the area may be crewed using LAMBS AI. The system also allows reserves to be specified and called.

Most of the mod features can be done by script if you wish to avoid dependencies.


BASIC USE
Place a DDAI Defensive Area module at the center of the desired area
Select the desired values in the editor
(ATTACK ONLY) Place a marker at the position to attack and put the marker name in the "Attack marker name" field
(OPTIONAL) Using the Eden "Placement Radius" option on groups is a quick and easy way to randomize a mission


OPTIONS
Side
Posture (Defend, DefendFlexible, Counter, Guard, Attack)
Facing
All-round defence
Radius
Position to attack (Attack orders only)
Delay before attack (Attack orders only)
Delay before counter-attack (Counter orders only)
Distance from enemy before triggering counter attack (Counter orders only)
Counter attack composition (infantry, vehicles, both, random)
Camo scheme (green or brown)
Bunker chance (chance an ungarrisoned infantry squad will spawn a bunker to garrison)
Camo net chance (chance a vehicle will spawn a camo net)
Delete ungarrisoned men  (true/false)
Delete empty statics (true/false)
Distance from other objects at which bunkers can spawn
Breakpoint before fleeing
Delay before start
Go codes required to start
Control over which bunker types are used


POSTURE TYPES
DEFEND: Groups stay in garrison, no extra WP
DEFENDFLEXIBLE: Groups stay in garrison with random exit conditions, vehicles may get guard WP
COUNTER: Groups will launch a counter attack once ground units are spotted and within range
GUARD: Groups stay in garrison with random exit conditions, all groups get guard WP
ATTACK: Groups will attack the target position


FLEEING
A random value between the two values provided will be generated. This is the percentage of men killed that will trigger allowFleeing 1 in all groups. To disable fleeing, put 0,0 in the field.


NOTES
Vehicles should be in groups of one
Mixed infantry/vehicle groups should have the leader in the vehicle
Air units will not be used by the system (use DAFS)
It is possible to extract the scripts and apply them at the mission level to avoid an addon dependency. This requires some basic scripting skills and I do not provide support for this approach.


EXCLUDING UNITS
_group setVariable["DDAIexclude",TRUE,TRUE];

For example, in a group's init field in the editor:
this setVariable["DDAIexclude",TRUE,TRUE];

Alternatively, sync a single unit from a group to the Exclude module.


GO CODES
Modules can be delayed from starting by putting a string or array of strings in the Go Code field. The module will not start until all of the listed go codes are in the server-side array ddaiGoCodes. For example:

[ddaiGocodes,"myGoCode_1"]remoteExec["pushBack",2];


RESERVES
Sync a single unit from each desired reserve group to a Reserves module and place the module at the location they should move to when called. The module must be within the radius of an Area module. Only the groups in that Area module can call those reserves. They will call reserves when one of the Area module groups detects land-based enemies within 1000m.


BUNKER TYPES
For more control over which types of bunkers will be spawned, place a Bunker Types module and sync it to the Area module.


CUSTOM BUNKER TYPES
Sync dummy bunkers (they will be deleted) to the Area module. Adjust the bunkers so that their front is pointing due north (0 degrees). The system will read the bunker types, check their visual facing versus their config facing to detect the required direction offset and delete the dummies. Note that syncing bunkers in this way will overwrite the default bunker selection, not add to it.

The direction setting is necessary as some bunkers have their rear or side angled to the north by default.


CLIPPING/REMOTE PLACEMENT ISSUES
This is related to BIS_fnc_findSafePos:
https://community.bistudio.com/wiki/BIS_fnc_findSafePos

You can adjust the minimum object distance in the Area module. Are larger value will prevent clipping, but may mean the script is unable to find a safe position and will spawn a bunker far from the Area.


KNOWN BUGS
Bunkers may sometimes clip with structures


HOW TO REPORT BUGS
1) Only report problems related to my original mods
2) Check the readme
3) Test it with no other mods, only vanilla assets and see if the problem persists
4) Avoid terms like "doesn't work" or "broken"
5) Describe the problem in detail
6) Give reproduction steps


LINUX USERS
Please read this if you are having issues:
https://community.bistudio.com/wiki/Arma_3:_Dedicated_Server#Case_sensitivity_.26_Mods


THEFT OF MY WORK
My artillery mod was stolen, edited and re-released in violation of the license by BlackAlpha of tier1ops.eu. Here is a video showing my original work and his stolen edit:

https://www.youtube.com/watch?v=Oe7G6WwxQVU

Please share this video and let the community know that BlackAlpha and tier1ops.eu are thieves.


CREDITS
Drongo:		Concept and coding


Special thanks to VedKay for all his work behind the scenes

A huge thanks to my Patrons and supporters:
Ahmad Fadhil Mohamed
Alexander Isaksson Norum
Alex Lacy
Andreas Nilson
Ave Sum
Azza
B. Hinton
Beags and Jam
Ben_at_Arms
Berl Ancell
Bretto1945
Bret Bothelio
Bruno Roberto Corrêa
Bullrich von Salz
Cedric Oliver
Chris Hall
Daniel Selby
David Catley
David Husa
David Kudýn
DavidSköld
Declan Emery
Desmond Abrams
Doctor
Elliot Taylor
EO
Fearmonger
Fetus114
Ferdinand
Frédérick Milhomme
Frosties
Gary Jackson
Gordon
gsg94490
Haakon Longbeard
Hogosha
Ian Schonely
Its_the_Jonah
James Hill
James tribbles
Jason Dotson
Jason Kieft
Jayrad
Jessica Ferguson
JimmyJamJams
Jonathan Harris
Karol Zaczek
Kelvin P
Kenneth Kilvington
Kevin Kelly
Logan Scott
LONEWOLF352
Longbeard
Marshall Bouldin
Matt Henderson
Magoo
MoonGuy
Nam
Nicholas Auger
Nicholas Odgers
Nick Gregory
Ole Petter Johnsen
Owen Siegfried
Paramarine Task Force
Paul T
Pernox
PHILLIP HARRIS
Proxno
Pusu npt
Ryan
Rolly uk
Roman Martinez
Sean Martin
sebastiaan reedijk
SETH BARCELLO
Sly
Slav_Man_Shae
Sonny Hermansen
Stuart Burling
swagggenius
Terrance
The One on the Rock
Timothy Hill
Tim O’Ceallaigh
Totem
tunou xiong
VedKay
ViperBAT46 DTF46
Wulf
WW3andMe
YonV
Zakuaz


CONTACT
The best place to contact me is my discord or by email.

drongomods@gmail.com
https://discord.gg/XSRHPEd
https://www.patreon.com/DrongoMods
https://www.youtube.com/channel/UCrZtKPYPS9iYzu1EAzTLYgg


LICENSE
Arma Public License Share Alive (APL-SA)
https://www.bohemia.net/community/licenses/arma-public-license-share-alike
Brief summary of this Licence

PLEASE, NOTE THAT THIS SUMMARY HAS NO LEGAL EFFECT AND IS ONLY OF AN INFORMATORY NATURE DESIGNED FOR YOU TO GET THE BASIC INFORMATION ABOUT THE CONTENT OF THIS LICENCE. THE ONLY LEGALLY BINDING PROVISIONS ARE THOSE IN THE ORIGINAL AND FULL TEXT OF THIS LICENCE.

With this licence you are free to adapt (i.e. modify, rework or update) and share (i.e. copy, distribute or transmit) the material under the following conditions:

    Attribution - You must attribute the material in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the material).
    Noncommercial - You may not use this material for any commercial purposes.
    Arma Only - You may not convert or adapt this material to be used in other games than Arma.
    Share Alike - If you adapt, or build upon this material, you may distribute the resulting material only under the same license.

In addition to the above license, the following conditions apply:
Nobody associated with tier1ops.eu may use, edit or distribute this mod or any derivatives thereof.
This addon may not be used as a tool by any corporate, government, military, law enforcement or security groups/individuals.
This addon may not be used for any commercial purpose.
This addon may not be used for training purposes.

If you need an exception, please contact me.


CHANGELOG
0.13
Fixed:		Errors with Attack orders

0.12
Added:		Custom bunker support
Fixed:		Error with facing code

0.11
Added:		Debug option
Added:		Face out option for bunkers
Fixed:		Reserves not moving when called
Improved:	Bunker position finding

0.1
First release